﻿<ad:DockableContent x:Class="Notoric.Gui.Windows.ProjectExplorer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
        xmlns:ls="clr-namespace:LukasKopenec.LocalizationSupport;assembly=LocalizationSupport"
        xmlns:vm="Notoric.ViewModel;assembly=ViewModel"
        xmlns:ctrls="clr-namespace:Notoric.Gui.Controls"
        Title="{ls:Localize ProjectExplorer.Title}"
        x:Name="parentControl">
    <DockPanel LastChildFill="True">
        <TreeView x:Name="projectTree"
                  DataContext="{Binding ElementName=parentControl}"
                  ItemsSource="{Binding Path=Projects, Mode=OneWay}"
                  MouseDoubleClick="projectTree_MouseDoubleClick"
                  KeyDown="projectTree_KeyDown"
                  >
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Path=Children, Mode=OneWay}">
                    <StackPanel Orientation="Horizontal" ContextMenu="{Binding Path=ContextMenu, Mode=OneWay}">
                        <Image Source="{Binding Path=Icon, Mode=OneWay}" Height="16" Width="16" Margin="0 0 4 0"/>
                        <ctrls:EditableTextBlock DataContext="{Binding}" IsInEditMode="{Binding IsInEditMode, Mode=TwoWay}"/>
                    </StackPanel>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
			
			<TreeView.ItemContainerStyle>
				<Style TargetType="{x:Type TreeViewItem}">
					<Setter Property="IsSelected" Value="{Binding Path=IsSelected,Mode=TwoWay}"/>
                    <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}"/>
                    <EventSetter Event="MouseRightButtonDown" Handler="TreeViewItem_MouseRightButtonDown"/>
				</Style>
			</TreeView.ItemContainerStyle>
        </TreeView>        
    </DockPanel>
</ad:DockableContent>
